<?php
include("template_top.php");
$sql = "SELECT * FROM tbCows WHERE `iID` = :id";
$COWS = db::Query($sql, array(':id'=>$_GET['cow']));
$row = $COWS->fetch();
?>
<h1>COW Tracker</h1>
<table>
    <tr>
        <td>Computer Name:</td>
        <td><input type="text" id="sCompName" value="<?php echo $row['sCompName'] ?>"/></td>
    </tr>
    <tr>
        <td>Last Known Location:</td>
        <td><input type="text" id="sLKL" value="<?php echo $row['sLKL'] ?>"/></td>
    </tr>
    <tr>
        <td>Operating System:</td>
        <td>
            <select id="sOS">
                <option <?php if($row['sOS'] == 'Microsoft Windows XP'){echo "selected";} ?>>Microsoft Windows XP</option>
                <option <?php if($row['sOS'] == 'Microsoft Windows XP - SP1'){echo "selected";} ?>>Microsoft Windows XP - SP1</option>
                <option <?php if($row['sOS'] == 'Microsoft Windows XP - SP2'){echo "selected";} ?>>Microsoft Windows XP - SP2</option>
                <option <?php if($row['sOS'] == 'Microsoft Windows XP - SP3'){echo "selected";} ?>>Microsoft Windows XP - SP3</option>
                <option <?php if($row['sOS'] == 'Microsoft Windows Vista'){echo "selected";} ?>>Microsoft Windows Vista</option>
                <option <?php if($row['sOS'] == 'Microsoft Windows Vista - SP1'){echo "selected";} ?>>Microsoft Windows Vista - SP1</option>
                <option <?php if($row['sOS'] == 'Microsoft Windows Vista - SP2'){echo "selected";} ?>>Microsoft Windows Vista - SP2</option>
                <option <?php if($row['sOS'] == 'Microsoft Windows 7'){echo "selected";} ?>>Microsoft Windows 7</option>
            </select>
        </td>
    </tr>
    <tr>
        <td valign="top">Software:</td>
        <td><textarea rows="10" cols="30" id="sSoft"><?php echo str_replace('<br/>', "\r", $row['sSoft']) ?></textarea></td>
    </tr>
    <tr>
        <td valign="top">Hardware:</td>
        <td><textarea rows="10" cols="30" id="sHard"><?php echo str_replace('<br/>', "\r", $row['sHard']) ?></textarea></td>
    </tr>
    <tr>
        <td></td>
        <td><input type="button" value="Update <?php echo $row['sName'] ?>" onclick="window.location = 'Cow_Tracker.php?iID=<?php echo $_GET['cow'] ?>&sCompName='+escape(document.getElementById('sCompName').value)+'&sLKL='+escape(document.getElementById('sLKL').value)+'&sOS='+document.getElementById('sOS').value+'&sSoft='+document.getElementById('sSoft').value.replace('\r', '<br/>')+'&sHard='+document.getElementById('sHard').value.replace('\n', '<br/>');"/></td>
    </tr>
</table>